package com.digiwin.middleware.configuration;

import com.digiwin.middleware.properties.DigiwinMiddlewareProperties;
import com.digiwin.middleware.service.IamService;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @Author yanggld
 * @Date 2020/2/14-17:15
 * @Description
 */
@Configuration
@EnableConfigurationProperties(DigiwinMiddlewareProperties.class)
public class AutoConfiguration {

	@Bean
	@ConditionalOnMissingBean
	@ConditionalOnProperty(value = "digiwin.middleware.iamAddress")
	public IamService iamService() {
		return new IamService();
	}


	@Bean
	@ConditionalOnMissingBean
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}

}
